package com.itheima.patterns.builderpattern.singleton.runtimedemo;

import java.io.IOException;
import java.io.InputStream;

public class RunTimeDemo {
    
    public static void main(String[] args) throws IOException {
        //获取RunTime类对象
        Runtime runtime = Runtime.getRuntime();
    
        System.out.println("JVM空闲内存=" + runtime.freeMemory()/(1024*1024) + "M");
        System.out.println("JVM总内存=" + runtime.totalMemory()/(1024*1024) + "M");
        System.out.println("JVM可用最大内存=" + runtime.maxMemory()/(1024*1024) + "M");
        
        //调用runtime的方法exec，参数为一个命令
        Process process = runtime.exec("ipconfig");
        //调用process对象的获取输入流的方法
        InputStream is = process.getInputStream();
        byte[] arr = new byte[1024 * 1024 * 100];
        int length = is.read(arr);
        System.out.println(new String(arr,0,length,"GBK"));
    }
}